<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>用户管理</title>
    <link rel="shortcut icon" th:href="@{/img/favicon.ico}"/>
    <link rel="bookmark" th:href="@{/img/favicon.ico}" type="image/x-icon"/>
    <link th:href="@{/css/style.css}" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" th:src="@{/js/jquery.js}"></script>
    <script type="text/javascript">
        function tipOpen(content,num,chagestate) {
            $(".tipright p").text(content);
            $("#tip").fadeIn(200);
            $("#uid").val(num);
            $("#chagestate").val(chagestate);
        }

        function tipClose() {
            $("#tip").fadeOut(200);
            var uid=$("#uid").val();
            var chagestate=$("#chagestate").val();
            location.href="/erp1/sys/users/updatestate?id="+uid+"&changestate="+chagestate;
            // $.get("",{"id":wid,"changestate":chagestate},function (data) {
            // }),"json";
        }

        function tipClose2() {
            $("#tip").fadeOut(200);
        }
    </script>
</head>

<body>
<div class="place"><span>位置：</span>
    <ul class="placeul">
        <li><a th:href="@{/sys/users/userall}">系统管理</a></li>
        <li><a th:href="@{/sys/users/userall}">用户管理</a></li>
    </ul>
</div>
<div class="rightinfo">
    <form th:action="@{/sys/users/userall}" method="post" id="userform">
        <input type="hidden" name="pageno" value="1" id="pageno"/>
        <ul class="tools">
            <li><label>员工编号:</label>
                <input type="text" name="uId" th:value="${user.uId}"/>
            </li>
            <li><label>员工姓名:</label>
                <input type="text" name="uname" th:value="${user.uname}"/>
            </li>
            <li><label>所属部门：</label>
                <select name="deptId">
                    <option value="0">请选择部门</option>
                    <option th:each="d : ${session.depts}" th:value="${d.deptId}" th:text="${d.deptName}"
                            th:selected="${d.deptId==user.deptId?'true':'false'}"></option>
                </select>
            </li>
            <li><label>状态：</label>
                <select name="statusId">
                    <option value="0">请选择</option>
                    <option value="1" th:selected="${user.statusId==1}?'true':'false'">在职</option>
                    <option value="2" th:selected="${user.statusId==2}?'true':'false'">离职</option>
                </select>
            </li>
            <li class="subBut" onclick="goPage(1)"><img th:src="@{/images/t06.png}"/>查询</li>
            <li class="subBut" onclick="window.location.href='userAdd.html'"><img th:src="@{/images/t01.png}"/>添加</li>
            <li class="subBut" onclick="reset()"><img th:src="@{/images/t03.png}"/>重置</li>
        </ul>
        <table class="tablelist">
            <thead>
            <tr>
                <th>序号</th>
                <th>员工编号</th>
                <th>员工姓名</th>
                <th>联系电话</th>
                <th>所属部门</th>
                <th>职位</th>
                <th>性别</th>
                <th>年龄</th>
                <th>状态</th>
                <th>入职时间</th>
                <th>离职时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <tr th:each="u,var : ${upinfo.list}">
                <td th:text="${(upinfo.pageNum-1)*upinfo.pageSize+var.count}"></td>
                <td th:text="${u.uId}"></td>
                <td th:text="${u.uname}"></td>
                <td th:text="${u.utelephone}"></td>
                <td th:text="${u.dept.deptName}"></td>
                <td th:text="${u.job.jobName}"></td>
                <td th:text="${u.sex==1?'男':'女'}"></td>
                <td th:text="${u.age}"></td>
                <td th:text="${u.statusId==1?'在职':'离职'}"></td>
                <td th:text="${#dates.format(u.hiredate,'yyyy/MM/dd')}"></td>
                <td th:text="${#dates.format(u.leavedate,'yyyy/MM/dd')}"></td>
                <input type="hidden" id="chagestate"/>
                <input type="hidden" id="uid"/>
                <td>
                    <a th:href="@{'/sys/users/goUpdate/'+${u.uId}}" class="tablelink">修改</a>
                    <a th:href="@{'/sys/users/details/'+${u.uId}}" class="tablelink">详情</a>
                    <a href="javascript:void(0)" th:if="${u.statusId==1}" class="tablelink" th:onclick="@{'tipOpen(\'您确定此员工离职吗？\','+${u.uId}+',2)'}">离职</a>
                    <a href="javascript:void(0)" th:if="${u.statusId==2}" class="tablelink" th:onclick="@{'tipOpen(\'您确定此员工复职吗？\','+${u.uId}+',1)'}">复职</a>
                </td>
            </tr>
            </tbody>
        </table>
        <div class="pagin">
            <div class="message">共<i class="blue" th:text="${upinfo.total}"></i>条记录，当前显示第&nbsp;<i class="blue" th:text="${upinfo.pageNum}">2&nbsp;</i>页</div>
            <ul class="paginList">
                <li class="paginItem">
                    <a href="javascript:void(0);" th:onclick="goPage([[${upinfo.isFirstPage?1:upinfo.pageNum-1}]])">
                        <span th:class="${upinfo.isFirstPage?'pagepre':'pagenxt roate'}"></span>
                    </a>
                </li>
                <li th:class="${page==upinfo.pageNum?'paginItem current':'paginItem'}"
                    th:each="page : ${upinfo.navigatepageNums}">
                    <a href="javascript:;"  th:text="${page}" th:onclick="goPage([[${page}]])">1</a>
                </li>
                <li class="paginItem">
                    <a href="javascript:void(0);" th:onclick="goPage([[${upinfo.isLastPage?upinfo.pages:upinfo.pageNum+1}]])">
                        <span th:class="${upinfo.isLastPage?'pagepre roate':'pagenxt'}"></span>
                    </a>
                </li>
            </ul>
        </div>
    </form>
    <!-- 提示框 -->
    <div id="tip" class="tip">
        <div class="tiptop"><span>提示信息</span><a onclick="tipClose()"></a></div>
        <div class="tipinfo"><span><img th:src="@{/images/ticon.png}"/></span>
            <div class="tipright">
                <p></p>
                <cite>如果是请点击确定按钮 ，否则请点取消。</cite></div>
        </div>
        <div class="tipbtn">
            <input name="" type="button" class="sure" value="确定" onclick="tipClose()"/>
            &nbsp;
            <input name="" type="button" class="cancel" value="取消" onclick="tipClose2()"/>
        </div>
    </div>
</div>
<script type="text/javascript">
    $('.tablelist tbody tr:odd').addClass('odd');
    //submit提交
    function goPage(num) {
        // alert(num);
        $("#pageno").val(num);
        $("#userform").submit();
    }

    function reset() {
        $("input[name=uId]").val("");
        $("input[name=uname]").val("");
        $("select[name=deptId]>option:eq(0)").attr("selected","true");
        $("select[name=statusId]>option:eq(0)").attr("selected","true");
    }
</script>
</body>
</html>
